﻿using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Xml;

namespace NColony.Syndication.Receiver.Contracts
{
    /// <summary>
    /// Contract for <see cref="ISyndicationReader&lt;TFeed&gt;"/>.
    /// </summary>
    /// <typeparam name="TFeed">The type of the feed.</typeparam>
    [ContractClassFor(typeof(ISyndicationReader<>))]
    public abstract class ISyndicationReaderContract<TFeed> : ISyndicationReader<TFeed>
        where TFeed : ISyndicationFeed
    {
        /// <summary>
        /// Reads the specified XML reader.
        /// </summary>
        /// <param name="xmlReader">The XML reader.</param>
        [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "xmlReader", Justification = "Contracts don't use params.")]
        public void Read(XmlReader xmlReader)
        {
            Contract.Requires(xmlReader != null, "xmlReader cannot be null or empty");
        }

        /// <summary>
        /// Gets or sets the feed.
        /// </summary>
        /// <value>The feed.</value>
        public ISyndicationFeed Feed
        {
            get
            {
                Contract.Ensures(Contract.Result<ISyndicationFeed>() != null, "Return value will never be null");

                return default(ISyndicationFeed);
            }
        }

#pragma warning disable 0067
        /// <summary>
        /// Occurs when a property value is changing.
        /// </summary>
        public event PropertyChangingEventHandler PropertyChanging;

        /// <summary>
        /// Occurs when a property value changes.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;
#pragma warning restore 0067
    }
}
